package com.myapp.web.action.nag;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.interceptor.ServletRequestAware;

import com.myapp.service.user.UserBo;
import com.myapp.web.filter.AuthFilter;
import com.opensymphony.xwork2.ActionSupport;

public class LoginAction extends ActionSupport implements ServletRequestAware{
	
	private static final long serialVersionUID = -4051097642887589287L;
	
	private HttpServletRequest request;

	public void setUserBo(UserBo userBo) {
		this.userBo = userBo;
	}

	private UserBo userBo;
	
	private String userid;
	
	private String passwd;
	
	private String keepSignInOption;
	
	public void setUserid(String userid) {
		this.userid = userid;
	}

	public void setPasswd(String passwd) {
		this.passwd = passwd;
	}

	public void setKeepSignInOption(String keepSignInOption) {
		this.keepSignInOption = keepSignInOption;
	}

	@Override
	public String execute() throws Exception { 
		if(userBo.login(userid, passwd)){
			this.request.getSession().setAttribute(AuthFilter.LOGIN_SESSION_KEY, true);
			return SUCCESS;
		}else
		{
			return INPUT ;
		}
	}

	@Override
	public void setServletRequest(HttpServletRequest request) {
		this.request = request ;		
	}
}
